export function getScrollParent(el) {
  let _parent = el.parentNode;

  while (_parent) {
    //getComputedStyle获取css属性值
    const styleOverflow = getComputedStyle(_parent)['overflow'];
    // // console.log(styleOverflow); //visible/auto

    // //当overflow: scroll/auto 时 证明是滚动的父元素
    if (/(scroll)|(auto)/.test(styleOverflow)) {
      return _parent;
    }

    // //找不到时继续往上找
    _parent = _parent.parentNode;
  }
}

export function imgLoad(src) {
  return new Promise((resolve, reject) => {
    const oImg = new Image();
    oImg.src = src;
    oImg.onload = resolve;
    oImg.onerror = reject;
  });
}
